home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja13.exe / lha / FREYJA.H < prev    next >
C/C++ Source or Header  |  1992-03-22  |  16KB  |  591 lines

  1. /* FREYJA.H -- Freyja Header File
  2.  
  3.     Written 1980 by Mark of the Unicorn, Inc.
  4.     Rewritten 1991 by Craig A. Finseth
  5.  
  6. */
  7.  
  8. /* -------------------- We Begin -------------------- */
  9.  
  10. #include "fgenlib.h"
  11.  
  12. #if defined(MSDOS)
  13. #if defined(MAIN)
  14. #define STACKSIZE    ((10 * 1024) / 16);
  15. int _stklen = STACKSIZE;
  16. #endif
  17. #endif
  18.  
  19. #if defined(BERK43) || defined(UNIXV)
  20. #define UNIX        1
  21. #endif
  22.  
  23. #if defined(UNIX)
  24. char *getenv();
  25. #endif
  26.  
  27. #if defined(SYSMGR)
  28. #undef CALC
  29. #endif
  30.  
  31. /* -------------------- Constants -------------------- */
  32.  
  33.     /* amount of time to delay for delayed echos -- this is a loop count*/
  34. #if defined(MSDOS)
  35. #define DELAYCOUNT    0
  36. #else
  37. #define DELAYCOUNT    1000
  38. #endif
  39.  
  40.     /* size of the largest terminal to handle */
  41. #if defined(MSDOS)
  42. #define ROWMAX        25
  43. #define COLMAX        80
  44. #else
  45. #define ROWMAX        132
  46. #define COLMAX        240
  47. #endif
  48.  
  49.     /* preference items */
  50. #define HOVERLAP    5        /* columns to overlap for h. scroll */
  51. #define VOVERLAP    2        /* lines to overlap for ^V */
  52. #define PREF_PCT    40        /* preferred row as a % 0-100 */
  53. #define MACROMAX    128        /* max size of a keybaord macro */
  54.  
  55.     /* universal global declarations */
  56. #define    FORWARD        1
  57. #define    BACKWARD    0
  58.  
  59.     /* file names for help */
  60. #if !defined(NOCALC)
  61. #define CALCULATOR_FILE    "fcalc.doc"
  62. #endif
  63. #define CMDLIST_FILE    "fcmdlist.doc"
  64. #define COPYING_FILE    "fcopying.doc"
  65. #define FSF_FILE    "ffsf.doc"
  66. #define INFO_FILE    "freyja.doc"
  67. #define LEAGUE_FILE    "fleague.doc"
  68. #define XREF_FILE    "fcmdxref.doc"
  69. #define TUTORIAL_FILE    "ftutoria.doc"
  70. #define WARRANTY_FILE    "fwarrant.doc"
  71.  
  72.     /* maximum limits */
  73. #define    STRMAX        40        /* size of a response */
  74. #define LINEBUFFSIZE    255        /* size of an output line buffer */
  75. #define SMALLBUFFSIZE    33
  76.  
  77. #define BIGBUFFSIZE    (FNAMEMAX)    /* largest of FNAMEMAX and previous
  78.                     buffer sizes */
  79. #define NUMBUFFERS    12        /* buffers */
  80.  
  81. #define ZCQ        '\021'        /* ^Q */
  82. #define ZCX        '\030'        /* ^X */
  83. #define ZCZ        '\032'        /* ^Z */
  84. #define SNL        '\037'        /* "soft" newline, ^_ */
  85.  
  86.     /* pseudo-key definitions */
  87. #define KEYNONE        (-1)        /* no valid key */
  88. #define KEYABORT    (-2)
  89. #define KEYQUIT        (-3)
  90.  
  91.     /* for visible grayspace */
  92. #if defined(UNIX)
  93. #define VIS_SPACE_CHAR    '.'
  94. #define VIS_TAB_CHAR    '>'
  95. #define VIS_NL_CHAR    '<'
  96. #endif
  97. #if defined(MSDOS)
  98. #define VIS_SPACE_CHAR    '\372'
  99. #define VIS_TAB_CHAR    '\020'
  100. #define VIS_NL_CHAR    '\021'
  101. #define KEYHELP        (0x100 + 59)
  102. #endif
  103.  
  104. /* -------------------- Configuration Settings -------------------- */
  105.  
  106. #define INI_FILENAME    "freyja.ini"
  107.  
  108. struct conf_buffer {
  109.     int left_margin;    /* indent column */
  110.     int right_margin;    /* fill column */
  111.     int tab_spacing;    /* tab stop spacing */
  112.     char fill;        /* filling mode */
  113.     };
  114.  
  115. struct conf_global {
  116.     char screen_type;    /* screen type */
  117.     char screen_size;    /* screen size */
  118.     char key_type;        /* keyboard input */
  119.     char special;        /* special handling */
  120.     char parameter_1;    /* parameter 1 */
  121.     int swap_size;        /* default swap area size in Kbytes */
  122.     int ESC_swap;        /* swap Esc and this char (27 for no swap) */
  123.     char meta_handle;    /* bit 2^8 in a character */
  124.     FLAG wrap_allowed;    /* check for word wrap files */
  125.     FLAG vis_gray;        /* True if grayspace is visible, False if not*/
  126.     FLAG use_caret;        /* True if carat notatio */
  127.     };
  128.  
  129. struct conf {
  130.     struct conf_buffer d;
  131.     struct conf_global g;
  132.     };
  133.  
  134. #if defined(MAIN)
  135. struct conf c;
  136. #else
  137. extern struct conf c;
  138. #endif
  139.  
  140. /* -------------------- Windows -------------------- */
  141.  
  142. #define NUMWINDOWS    2
  143.  
  144. struct window {
  145.     FLAG visible;        /* is the window visible/in use? */
  146.     int top;        /* first line of window */
  147.     int bot;        /* last line of window */
  148.     struct mark *sstart;    /* mark at the start of the window */
  149.     struct mark *send;    /* mark at the end of the window */
  150.     FLAG isend;        /* is the end mark valid? */
  151.     struct mark *point;    /* the point */
  152.     int offset;        /* the horizontal offset */
  153.     };
  154.  
  155. #if defined(MAIN)
  156. struct window windows[NUMWINDOWS];
  157. struct window *cwin;        /* the current window */
  158. int num_windows;        /* number of windows being displayed */
  159. #else
  160. extern struct window windows[NUMWINDOWS];
  161. extern struct window *cwin;
  162. extern int num_windows;
  163. #endif
  164.  
  165. /* -------------------- Buffers -------------------- */
  166.  
  167. #define    PAGESIZE    1024        /* page size in bytes */
  168. #define    SWAPMAX        256        /* maximum number of pages */
  169. #define NUM_PHYS_PAGES    16        /* number of pages in memory */
  170.  
  171. #define    MAXMARK        (2 * NUMBUFFERS + 4 * NUMWINDOWS + 4)
  172.  
  173. struct virt_page {
  174.     struct virt_page *next;        /* chain of pages in buffer */
  175.     struct virt_page *prev;
  176.     char where;            /* where page is M-memory, S-swap,
  177.                     L-locked */
  178.     int page_num;            /* page number in the swap area */
  179.     int gap_start;            /* gap start */
  180.     int page_len;            /* page length */
  181.     };
  182.  
  183. struct mark {
  184.     struct virt_page *pptr;        /* page in the buffer */
  185.     struct buffer *bptr;        /* buffer the mark is in */
  186.     int mark_offset;        /* offset in the page */
  187.     FLAG is_mod;            /* screen mark modified flags */
  188.     };
  189.  
  190. struct buffer {
  191.     char fname[FNAMEMAX];        /* the file name */
  192.     struct conf_buffer c;        /* configuration parameters */
  193.     struct mark *mptr;        /* the mark */
  194.     struct virt_page *first;    /* describe the pages */
  195.     struct virt_page *last;
  196.     struct virt_page *point_page;    /* point's page number */
  197.     int point_offset;        /* offset within page */
  198.     int num_pages;            /* number of pages in buffer */
  199.     FLAG is_mod;            /* has the buffer been modified? */
  200. #ifdef UNIX
  201.     long file_time;
  202. #endif
  203.     };
  204.  
  205. #if defined(MAIN)
  206. struct buffer buffers[NUMBUFFERS];
  207. #else
  208. extern struct buffer buffers[NUMBUFFERS];
  209. #endif
  210.  
  211.     /* current buffer information */
  212. #if defined(MAIN)
  213. struct buffer *cbuf;            /* the curent buffer */
  214. struct mark *mark;            /* the current mark */
  215. #else
  216. extern struct buffer *cbuf;
  217. extern struct mark *mark;
  218. #endif
  219.  
  220.     /* system buffer support */
  221. #define IS_SYS(x)    (*(x) == '%')
  222. #define SYS_BUFFLIST    "%bufflist%"
  223. #define SYS_DIRED    "%dired%"
  224. #define SYS_HELP    "%help%"
  225. #define SYS_KILL    "%kill%"
  226. #define SYS_SCRATCH    "%scratch%"
  227.  
  228. /* -------------------- Globals -------------------- */
  229.  
  230. #if defined(MAIN)
  231. int lastkey;        /* the last command key given */
  232. int lasttable;        /* the last prefix table used */
  233. int key;        /* the current command key */
  234. int table;        /* the current command table */
  235.  
  236. int uarg;        /* command argument */
  237. FLAG isuarg;        /* was there an argument? */
  238. FLAG isrepeating;    /* are we on the second or later repetition? */
  239. FLAG doabort;        /* do we leave the editor? */
  240.  
  241. struct buffer *kill_buf;    /* kill buffer */
  242.  
  243. char stringarg[STRMAX];    /* last string entered */
  244. char filearg[FNAMEMAX];    /* last filename entered */
  245. #else
  246. extern int lastkey;
  247. extern int lasttable;
  248. extern int key;
  249. extern int table;
  250. extern int uarg;
  251. extern FLAG isuarg;
  252. extern FLAG isrepeating;
  253. extern FLAG doabort;
  254. extern struct buffer *kill_buf;
  255. extern char stringarg[STRMAX];
  256. extern char filearg[FNAMEMAX];
  257. #endif
  258.  
  259. /* -------------------- Routines -------------------- */
  260.  
  261.     /* buf.c */
  262.  
  263. FLAG BInit();        /* int swap_size */
  264. void BFini();        /* void */
  265. struct buffer *BBufCreate();    /* char *fname */
  266. void BBufDelete();    /* struct buffer *bptr */
  267. struct buffer *BBufFind();    /* char *name */
  268. void BBufGoto();    /* struct buffer *bptr */
  269. void BBufUnmod();    /* void */
  270. void BCharChange();    /* char new */
  271. void BCharDelete();    /* int amount */
  272. FLAG BFileRead();    /* void */
  273. FLAG BFileWrite();    /* void */
  274. void BFlush();        /* void */
  275. char BGetChar();    /* void */
  276. char BGetCharAdv();    /* void */
  277. int BGetCol();        /* void */
  278. long BGetLength();    /* struct buffer *bptr */
  279. long BGetLocation();    /* void */
  280. FLAG BInsChar();    /* char new */
  281. void BInsSpaces();    /* int amount */
  282. FLAG BInsString();    /* char *str */
  283. void BInsTabSpaces();    /* int amount */
  284. void BInvalid();    /* void */
  285. FLAG BIsAfterMark();    /* struct mark *mptr */
  286. FLAG BIsAtMark();    /* struct mark *mptr */
  287. FLAG BIsBeforeMark();    /* struct mark *mptr */
  288. FLAG BIsEnd();        /* void */
  289. FLAG BIsFree();        /* struct buffer *bptr */
  290. FLAG BIsMod();        /* struct buffer *bptr */
  291. FLAG BIsStart();    /* void */
  292. void BMakeColB();    /* int col */
  293. void BMakeColF();    /* int col */
  294. struct buffer *BMarkBuf(); /* struct mark *mptr */
  295. struct mark *BMarkCreate(); /* void */
  296. void BMarkDelete();    /* struct mark *mptr */
  297. FLAG BMarkIsMod();    /* struct mark *mptr */
  298. void BMarkSetMod();    /* struct mark *mptr */
  299. struct mark *BMarkScreen();    /* int row */
  300. void BMarkSwap();    /* struct mark *mptr */
  301. void BMarkToPoint();    /* struct mark *mptr */
  302. void BMoveBy();        /* int amount */
  303. void BMoveToEnd();    /* void */
  304. void BMoveToStart();    /* void */
  305. void BPointToMark();    /* struct mark *mptr */
  306. void BPopState();    /* void */
  307. void BPushState();    /* void */
  308. void BRegCopy();    /* struct mark *mptr, struct buffer *bptr */
  309. void BRegDelete();    /* struct mark *mptr */
  310. FLAG BSearchB();    /* char c1, char c2 */
  311. FLAG BSearchF();    /* char c1, char c2 */
  312.  
  313.     /* calc.c */
  314.  
  315. #if !defined(NOCALC)
  316. void UInit();        /* void */
  317. void UCalc();        /* void */
  318. char *UDescr();        /* int operation */
  319. void UEnter();        /* void */
  320. char *UHelp();        /* int operation */
  321. void ULoadMac();    /* void */
  322. int UNumOps();        /* void */
  323. void UPrintX();        /* void */
  324. void USetup();        /* FLAG iscomma, FLAG issep */
  325. #endif
  326.  
  327.     /* char.c */
  328.  
  329. void CCharB();        /* void */
  330. void CCharBD();        /* void */
  331. void CCharF();        /* void */
  332. void CCharFD();        /* void */
  333. void CCharTran();    /* void */
  334. void CLineA();        /* void */
  335. void CLineAED();    /* void */
  336. void CLineB();        /* void */
  337. void CLineE();        /* void */
  338. void CLineF();        /* void */
  339. void CLineFD();        /* void */
  340. void CScrnB();        /* void */
  341. void CScrnBOW();    /* void */
  342. void CScrnF();        /* void */
  343. void CScrnFOW();    /* void */
  344.  
  345.     /* date.c */
  346.  
  347. void DCal();        /* void */
  348. void DMove();        /* int amout */
  349. void DNext();        /* void */
  350. void DNow();        /* struct tm *tptr */
  351. int DOW();        /* long day */
  352. void DPrev();        /* void */
  353. void DSetup();        /* int weekstart, int datefmt, int timefmt */
  354. void DToDate();        /* struct tm *tptr, long day, int cal */
  355. long DToDayN();        /* struct tm *tptr, int cal */
  356. #if !defined(SYSMGR)
  357. void DXCal();        /* struct tm *tptr */
  358. #endif
  359.  
  360.     /* display.c */
  361.  
  362. void DInit1();        /* void */
  363. void DInit2();        /* void */
  364. void DFini();        /* void */
  365. void DEcho();        /* char *msg */
  366. void DEchoNM();        /* char *msg */
  367. void DError();        /* char *msg */
  368. void DIncrDisplay();    /* void */
  369. #if defined(MSDOS)
  370. void DJMenus();        /* int which */
  371. #endif
  372. void DLeft();        /* void */
  373. void DModeFlags();    /* void */
  374. void DModeLine();    /* void */
  375. void DNewDisplay();    /* void */
  376. int DPrefLine();    /* void */
  377. void DRight();        /* void */
  378. void DScreenRange();    /* void */
  379. void DTogVisGray();    /* void */
  380. void DView();        /* char *msg */
  381. void DWindGrow();    /* void */
  382. int DWindHeight();    /* void */
  383. void DWindOne();    /* void */
  384. void DWindSwap();    /* void */
  385. void DWindTog();    /* void */
  386. void DWindTwo();    /* void */
  387. void DWindTwoO();    /* void */
  388.  
  389.     /* file.c */
  390.  
  391. void FBufBeg();        /* void */
  392. void FBufDel();        /* void */
  393. void FBufEnd();        /* void */
  394. void FBufList();    /* void */
  395. void FBufNext();    /* void */
  396. void FBufPrev();    /* void */
  397. #if !defined(NOEXEC)
  398. void FCommand();    /* void */
  399. #endif
  400. void FDIRED();        /* void */
  401. void FFileFind();    /* void */
  402. void FFileRead();    /* void */
  403. void FFileSave();    /* void */
  404. void FFileWrite();    /* void */
  405. FLAG FMakeSys();    /* char *name, FLAG erase */
  406. int FPathOpen();    /* char *name, char *actualname */
  407.  
  408.     /* help.c */
  409.  
  410. void HHelp();        /* void */
  411.  
  412.     /* ini.c */
  413.  
  414. FLAG IniLoad();        /* char screen, int size */
  415.  
  416.     /* jaguar.c */
  417.  
  418. #if defined(MSDOS)
  419. void JInit();        /* void */
  420. void JFini();        /* void */
  421. #if !defined(SYSMGR)
  422. void JAppt();        /* void */
  423. void JComm();        /* void */
  424. void JDisEnd();        /* void */
  425. void JDisStart();    /* void */
  426. void JFiler();        /* void */
  427. void JGetDir();        /* char *dname */
  428. int JGetKey();        /* void */
  429. void JHPCalc();        /* void */
  430. char JIsKey();        /* void */
  431. void JLotus();        /* void */
  432. void JMemo();        /* void */
  433. void JMenu();        /* void */
  434. void JPhone();        /* void */
  435. void JSetup();        /* void */
  436. #else
  437. void JDisEnd();        /* void */
  438. void JDisStart();    /* void */
  439. void JGetDate();    /* int *year, int *mon, int *day */
  440. void JGetDir();        /* char *dname */
  441. FLAG JGetFile();    /* char *prompt, char *fname */
  442. int JGetKey();        /* void */
  443. char JIsKey();        /* void */
  444. void JMenu();        /* void */
  445. void JMsg();        /* char *str */
  446. void JNoFini();        /* void */
  447. #endif
  448. #endif
  449.  
  450.     /* key.c */
  451.  
  452. int KAsk();        /* char *msg */
  453. void KBegMac();        /* void */
  454. FLAG KDelayPrompt();    /* char *msg */
  455. void KEndMac();        /* void */
  456. void KFromBuf();    /* struct buffer *bptr */
  457. void KFromMac();    /* void */
  458. void KFromStr();    /* char *str, int len */
  459. int KGetChar();        /* void */
  460. int KGetStr();        /* char *msg, char *str, int len */
  461. char KIsKey();        /* void */
  462. int *KMacPtr();        /* void */
  463. FLAG KUArg();        /* int targ */
  464.  
  465.     /* misc.c */
  466.  
  467. void GoToGray();    /* FLAG isforward */
  468. void GoToNotGray();    /* FLAG isforward */
  469. FLAG IsGray();        /* void */
  470. FLAG IsNL();        /* void */
  471. FLAG IsWhite();        /* void */
  472. void MAbort();        /* void */
  473. void MCtrlX();        /* void */
  474. void MExit();        /* void */
  475. void MIns8();        /* void */
  476. void MInsChar();    /* void */
  477. void MMakeDelete();    /* void */
  478. void MNotImpl();    /* void */
  479. void MMeta();        /* void */
  480. void MQuote();        /* void */
  481. void MReplace();    /* void */
  482. void MReplaceQ();    /* void */
  483. void MSearchB();    /* void */
  484. void MSearchF();    /* void */
  485. void MUArg();        /* void */
  486. void MovePastB();    /* FLAG (*pred)() */
  487. void MovePastF();    /* FLAG (*pred)() */
  488. void MoveToB();        /* FLAG (*pred)() */
  489. void MoveToF();        /* FLAG (*pred)() */
  490. FLAG SearchNLB();    /* void */
  491. FLAG SearchNLF();    /* void */
  492.  
  493.     /* region.c */
  494.  
  495. void RDelWhite();    /* void */
  496. void RHardToSoft();    /* void */
  497. void RIndent();        /* void */
  498. void RKillToMark();    /* struct mark * mptr, FLAG isforward */
  499. void RLower();        /* void */
  500. void RMarkSet();    /* void */
  501. void RMarkSwap();    /* void */
  502. void ROutdent();    /* void */
  503. void RRegCopy();    /* void */
  504. void RRegDelete();    /* void */
  505. void RSoftToHard();    /* void */
  506. void RTabify();        /* void */
  507. void RUntabify();    /* void */
  508. void RUpper();        /* void */
  509. void RYank();        /* void */
  510.  
  511.     /* table.c */
  512.  
  513. char *TabDescr();    /* int key, int table */
  514. void TabDispatch();    /* int key, int table */
  515. char *TabHelp();    /* int key, int table */
  516. int TabTable();        /* int key, int table */
  517. FLAG TabIsDelete();    /* int key, int table */
  518. FLAG TabIsVMove();    /* int key, int table */
  519. int TabNumFunc();    /* void */
  520.  
  521.     /* term.c */
  522.  
  523. FLAG TInit();        /* void */
  524. void TFini();        /* void */
  525. void TAdjCol();        /* void */
  526. void TBell();        /* void */
  527. void TCLEOL();        /* void */
  528. void TClrScreen();    /* void */
  529. void TForce();        /* void */
  530. int TGetCol();        /* void */
  531. int TGetKey();        /* void */
  532. int TGetOffset();    /* void */
  533. int TGetRow();        /* void */
  534. int TGetWidth();    /* char c, int column */
  535. void THiOff();        /* void */
  536. void THiOn();        /* void */
  537. FLAG TIsKey();        /* void */
  538. int TMaxCol();        /* void */
  539. int TMaxRow();        /* void */
  540. char *TPrintChar();    /* char c, char *buf */
  541. void TPutChar();    /* char c */
  542. void TPutStr();        /* char *str */
  543. void TSetOffset();    /* int offset */
  544. void TSetPoint();    /* int row, int column */
  545.  
  546.     /* white.c */
  547.  
  548. void WDelFWhite();    /* void */
  549. void WDelWhite();    /* void */
  550. void WFixup();        /* struct conf_buffer *cptr */
  551. void WIndNext();    /* void */
  552. void WIndDel();        /* void */
  553. void WIndThis();    /* void */
  554. void WInsNL();        /* void */
  555. void WInsNLA();        /* void */
  556. void WJoinGray();    /* void */
  557. void WLineCenter();    /* void */
  558. void WPrintLine();    /* void */
  559. void WPrintMar();    /* void */
  560. void WPrintPos();    /* void */
  561. void WSetFill();    /* void */
  562. void WSetLeft();    /* void */
  563. void WSetRight();    /* void */
  564. void WSetTabs();    /* void */
  565.  
  566.     /* word.c */
  567.  
  568. void WCaseRotate();    /* void */
  569. void WNumB();        /* void */
  570. void WNumF();        /* void */
  571. void WNumMark();    /* void */
  572. void WParaB();        /* void */
  573. void WParaF();        /* void */
  574. void WParaFill();    /* void */
  575. void WParaMark();    /* void */
  576. void WSentB();        /* void */
  577. void WSentBD();        /* void */
  578. void WSentF();        /* void */
  579. void WSentFD();        /* void */
  580. void WWordB();        /* void */
  581. void WWordBD();        /* void */
  582. void WWordCap();    /* void */
  583. void WWordF();        /* void */
  584. void WWordFD();        /* void */
  585. void WWordLow();    /* void */
  586. void WWordTran();    /* void */
  587. void WWordUp();        /* void */
  588. void WWrap();        /* void */
  589.  
  590. /* end of FREYJA.H -- Freyja Header File */
  591.